﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KYJControlLib
{
    public partial class DeviceState : UserControl
    {
        public DeviceState()
        {
            InitializeComponent();
            //设置控件样式
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.ResizeRedraw, false);
            this.SetStyle(ControlStyles.Selectable, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        }

        private byte state = 0;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("指示灯状态，0:停止;1:运行;2:故障;其他:备用")]
        public byte State
        {
            get { return state; }
            set
            {
                state = value;
                switch (state)
                {
                    case 0: this.BackgroundImage = Properties.Resources.Stop; break;
                    case 1: this.BackgroundImage = Properties.Resources.Run; break;
                    case 2: this.BackgroundImage = Properties.Resources.Fault; break;
                    default: this.BackgroundImage = Properties.Resources.Spare; break;
                }
            }
        }
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("绑定的变量名称")]
        public string BindVarName { get; set; }
    }
}
